import React from "react";
import Taro from "@tarojs/taro";
import { View } from "@tarojs/components";
import { IconFont } from "@nutui/icons-react-taro";
import styles from "./style.scss";
import { useModel } from "@/store";
export default function MenuItem(props) {
  const { title, subTitle, icon, url, background } = props;
  const { curPatientInfo } = useModel("patient");
  const toLink = () => {
    if (!curPatientInfo?.patientId) {
      Taro.showToast({
        title: "请先绑定就诊人",
        icon: "none",
      });
      return;
    }
    Taro.navigateTo({ url });
  };

  return (
    <View className={styles.item} onClick={toLink} style={{ background }}>
      <View className={styles.title}>{title}</View>
      <View className={styles.subtitle}>{subTitle}</View>
      <View className={styles.icon}>
        <IconFont name={icon} size={48} />
      </View>
    </View>
  );
}
